package com.woniu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.entity.PageResult;
import com.woniu.pojo.Magnet;
import com.woniu.pojo.Pda;
import com.woniu.mapper.PdaMapper;
import com.woniu.service.IPdaService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.vo.MagnetQueryVo;
import com.woniu.vo.PdaQueryVo;
import com.woniu.vo.PdaReturnVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author long
 * @since 2022-10-12
 */
@Service
public class PdaServiceImpl extends ServiceImpl<PdaMapper, Pda> implements IPdaService {

    @Autowired
    private PdaMapper pdaMapper;

    @Override
    public PageResult search(Integer currentPage, Integer pageSize, PdaQueryVo pdaQueryVo) {
        // 创建分页对象
        IPage iPage = new Page<>(currentPage, pageSize);
        // 构建查询对象
        /*QueryWrapper<Pda> wrapper = new QueryWrapper<>();
        if(pdaQueryVo != null){
            if(!StringUtils.isEmpty(pdaQueryVo.getName())){
                wrapper.like("name", pdaQueryVo.getName());
            }
            if(pdaQueryVo.getId() != null){
                wrapper.eq("id", pdaQueryVo.getId());
            }
        }*/
        // 调用mapper进行分页查询
        IPage<PdaReturnVo> pdaIPage = pdaMapper.searchPageByPda(iPage, pdaQueryVo);
        // 封装返回对象
        return new PageResult(pdaIPage.getTotal(), pdaIPage.getRecords());
    }

}
